Option Explicit
'ۭqҲ
Dim myTb() As myTbClass
Private Sub UserForm_Initialize()
    Dim i As Long
    ReDim myTb(1 To 5)
    For i = 1 To 5
        Set myTb(i) = New myTbClass
        Set myTb(i).Tb = Me.Controls("TextBox" & CStr(i))
    Next
    myTb(1).ck = 1
    myTb(2).ck = 2
    myTb(3).ck = 3
    myTb(4).ck = 2
    myTb(5).ck = 1
End Sub

'OҲmyTbClass
Private WithEvents myTb As MSForms.TextBox
Private myCkType As Long
Public Property Set Tb(setTb As MSForms.TextBox)
    Set myTb = setTb
End Property

Public Property Get Tb() As MSForms.TextBox
End Property

Public Property Let ck(setCk As Long)
    myCkType = setCk
End Property

Public Property Get ck() As Long
End Property

Private Sub myTb_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
    Select Case myCkType
        Case 1
            'ڵƦrH~J
            If KeyAscii < Asc("0") Or KeyAscii > Asc("9") Then
                KeyAscii = 0: Beep
            End If
        Case 2
            'ڵƦr,"-"H~J
            If (KeyAscii >= Asc("0") And _
                KeyAscii <= Asc("9")) Or KeyAscii = Asc("-") Then
            Else
                KeyAscii = 0: Beep
            End If
        Case 3
            'ڵƦr,"^jg"H~J
            If (KeyAscii >= Asc("0") And KeyAscii <= Asc("9")) Or _
                (KeyAscii >= Asc("A") And KeyAscii <= Asc("Z")) Then
            Else
                KeyAscii = 0: Beep
            End If
    End Select
End Sub
